package cn.edu.neusoft.maxingxin231.yuejian06.Fragment.Train;

import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import java.util.List;

import cn.edu.neusoft.maxingxin231.yuejian06.Adapter.RookieAdapter;
import cn.edu.neusoft.maxingxin231.yuejian06.Adapter.TrainAllAdapter;
import cn.edu.neusoft.maxingxin231.yuejian06.Bean.TrainBean;
import cn.edu.neusoft.maxingxin231.yuejian06.Listener.ListListener;
import cn.edu.neusoft.maxingxin231.yuejian06.Model.RookieModel;
import cn.edu.neusoft.maxingxin231.yuejian06.Model.TrainAllModel;
import cn.edu.neusoft.maxingxin231.yuejian06.R;

public class TrainAllFragment extends Fragment {
    String train_id;
    private View view=null;
    private Context context;
    private RecyclerView recycleview_all;
    private RecyclerView.LayoutManager layoutManager;
    private TrainAllAdapter trainAllAdapter;
    private List<TrainBean> items=null;
    ListListener<TrainBean> trainallebeanListListener=new ListListener<TrainBean>() {
        @Override
        public void onResponse(List<TrainBean> list) {
            Toast.makeText(context, "全部", Toast.LENGTH_SHORT).show();
            items = list;
            trainAllAdapter.setList(list);
        }

        @Override
        public void onFail(String msg) {
            Toast.makeText(context,"fail:"+msg,Toast.LENGTH_SHORT).show();
        }
    };
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        context=getActivity();
        view=inflater.inflate(R.layout.fragment_all,container,false);
        recycleview_all=(RecyclerView) view.findViewById(R.id.recyclerview_all);
        layoutManager=new LinearLayoutManager(context);
        recycleview_all.setLayoutManager(layoutManager);
        trainAllAdapter=new TrainAllAdapter(getActivity(),items,R.layout.club_card);
        trainAllAdapter.setList(items);

        recycleview_all.setAdapter(trainAllAdapter);
        TrainAllModel trainAllModel = new TrainAllModel();
        trainAllModel.getTrainAllList(trainallebeanListListener);
        return view;
    }
    public interface OnFragmentInteractionListener {
        // TODO: Update argument type and name
        void onFragmentInteraction(Uri uri);
    }
}
